//
//  CZStatusBottomView.swift
//  GZWeibo007
//
//  Created by Apple on 15/12/21.
//  Copyright © 2015年 Apple. All rights reserved.
//

import UIKit
protocol CZStatusBottomViewDelegate: NSObjectProtocol {
    func modalForwardButtonClick()
    func modalCommentButtomClick()
}

class CZStatusBottomView: UIView {
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    weak var delegate: CZStatusBottomViewDelegate?
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = UIColor(white: 0.9, alpha: 1)
        
        // 准备UI
        prepareUI()
        
        // 指定代理
        
    }

    // MARK: - 准备UI
    private func prepareUI() {
        // 添加子控件
        addSubview(forwardButton)
        addSubview(commentButton)
        addSubview(zanButton)
        addSubview(separatorViewFirst)
        addSubview(separatorViewSecond)
        
        
        forwardButton.addTarget(self, action: "forwardButtonClick:", forControlEvents: UIControlEvents.TouchUpInside)
        commentButton.addTarget(self, action: "commentButtonClick:", forControlEvents: UIControlEvents.TouchUpInside)
        // 添加约束
        // 3个按钮水平平铺父控件
        self.ff_HorizontalTile([forwardButton, commentButton, zanButton], insets: UIEdgeInsetsZero)
        
        // 分割线1
        separatorViewFirst.ff_AlignHorizontal(type: ff_AlignType.CenterRight, referView: forwardButton, size: nil)
        
        // 分割线2
        separatorViewSecond.ff_AlignHorizontal(type: ff_AlignType.CenterRight, referView: commentButton, size: nil)
        
    }
    
    func forwardButtonClick(forwardButton: UIButton) {
        delegate?.modalForwardButtonClick()
    }
    func commentButtonClick(commentButton: UIButton) {
        delegate?.modalCommentButtomClick()
    }

    // MARK: - 懒加载控件
    // 转发
 /*   lazy var forwardButton1: UIButton =  {
        let button = UIButton()
        // 设置图片
        button.setImage(UIImage(named: "timeline_icon_retweet"), forState: UIControlState.Normal)
        
        // 设置文字颜色
        button.setTitleColor(UIColor.lightGrayColor(), forState: UIControlState.Normal)
        
        // 设置文字大小
        button.titleLabel?.font = UIFont.systemFontOfSize(11)
        
        // 设置文字的内容
        button.setTitle("", forState: UIControlState.Normal)
        
        
        
        return button
    }()*/
    
    lazy var forwardButton: UIButton = UIButton(imageName: "timeline_icon_retweet", fontSize: 11, title: "转发")
    
    
    
    // 评论
    lazy var commentButton: UIButton = UIButton(imageName: "timeline_icon_comment", fontSize: 11, title: "评论")
    
    // 赞
    lazy var zanButton: UIButton = UIButton(imageName: "timeline_icon_unlike", fontSize: 11, title: "赞")
    
    // 分割线1
    private lazy var separatorViewFirst: UIImageView = UIImageView(image: UIImage(named: "timeline_card_bottom_line_highlighted"))
    
    // 分割线1
    private lazy var separatorViewSecond: UIImageView = UIImageView(image: UIImage(named: "timeline_card_bottom_line_highlighted"))
}
